﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Chaunce.FrameWork.NetCore.DapperCore;
using Autofac;
using Autofac.Builder;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;

namespace Chaunce.FrameWork.NetCore.IoC
{
    /// <summary>
    /// 全局 Autofac IOC 容器
    /// </summary>
    public static class IoCContainer
    {
        /// <summary>
        /// 入口对此初始化才可使用，例如在Startup： IoCContainer._container = new ContainerBuilder();
        /// </summary>
        public static IContainer _container;

        /// <summary>
        /// 从容器中解析默认请求类型的实例。
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <returns></returns>
        public static T Resolve<T>()
        {
            return _container.Resolve<T>();
        }
    }
}
